﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.BLL;
using CMS.Entity;

public partial class news_msn_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            YearProfileBLL bll = new YearProfileBLL();
            var lst = bll.GetAll();
            for (int i = lst.Count - 1; i >= 0; i--)
            {
                var c=lst[i];
                if (CommonBll.DicStocks.ContainsKey(lst[i].Stock))
                {
                    if (c.BussinessProfileFlag == true && c.BussinessProfileListFlag == true)
                    {
                         lst.Remove(lst[i]);
                    }
                    else
                    {
                        lst[i].StockName = CommonBll.DicStocks[lst[i].Stock];
                    }
                }
                else
                {
                    lst.Remove(lst[i]);
                }
            }
            repeater1.DataSource = lst.Take(200);
            repeater1.DataBind();
        }
    }

    public static string GetUpdateBussinessProfileStateStr(object obj)
    {
        YearProfile c = (YearProfile)obj;
        if (c.BussinessProfileFlag == true)
        {
            return "已设置";
        }
        else
        {
            return "<a href='UpdateBussinessProfileState.aspx?stock=" + c.Stock + "&EndDate=" + c.EndDate.ToString("yyyy-MM-dd") + "'>设置经营综述已填写</a>";
        }
    }

    public static string GetUpdateBussinessProfileListStateStr(object obj)
    {
        YearProfile c = (YearProfile)obj;
        if (c.BussinessProfileListFlag == true)
        {
            return "已设置";
        }
        else
        {
            return "<a href='UpdateBussinessProfileListState.aspx?stock=" + c.Stock + "&EndDate=" + c.EndDate.ToString("yyyy-MM-dd") + "'>设置经营范围已填写</a>";
        }
    }

    protected void btnQuery_Click(object sender, EventArgs e)
    {
        string stock = txtStock.Text;
        YearProfileBLL bll = new YearProfileBLL();
        var lst = bll.GetLst(stock);
        repeater1.DataSource = lst;
        repeater1.DataBind();
    }
    protected void btnDisplayAll_Click(object sender, EventArgs e)
    {
         YearProfileBLL bll = new YearProfileBLL();
            var lst = bll.GetAll();
            for (int i = lst.Count - 1; i >= 0; i--)
            {
                if (CommonBll.DicStocks.ContainsKey(lst[i].Stock))
                {
                    lst[i].StockName = CommonBll.DicStocks[lst[i].Stock];
                }
                else
                {
                    lst.Remove(lst[i]);
                }
            }
            repeater1.DataSource = lst;
            repeater1.DataBind();
    }
}